//
//  Swift_Global.swift
//  SDemo
//
//  Created by 余意 on 2016/11/29.
//  Copyright © 2016年 余意. All rights reserved.
//

import UIKit

let SCREEN_HEIGHTE = UIScreen.main.bounds.height
let SCREEN_WIDTH = UIScreen.main.bounds.width
let FIT_WIDTH = UIScreen.main.bounds.width / 375.0
let FIT_HEIGHT = UIScreen.main.bounds.height / 667.0

let SYSTEM_VERSION = UIDevice.current.systemVersion._bridgeToObjectiveC().doubleValue

let RANDOM_COLOR = RGBA(R: CGFloat(arc4random_uniform(256)), G: CGFloat(arc4random_uniform(256)),B: CGFloat(arc4random_uniform(256)), A:CGFloat(arc4random_uniform(1)))

let SYSTEM_COLOR            = RGBA(R: 249 , G: 145 , B : 0, A : 1)
let BACKGROUND_COLOR        = RGBA(R: 242 , G: 242 , B : 242 , A : 1)
let TEXT_PLACEHOLDER_COLOR  = RGBA(R: 204 , G : 204 , B : 204 , A : 1 )
let TEXT_BLACK_COLOR        = RGBA(R: 51 , G : 58 , B : 64 , A : 1)
let TEXT_RED_COLOR          = RGBA(R: 249 , G : 71 , B : 0 , A : 1)
let TEXT_GRAY_COLOR         = RGBA(R: 128 , G : 128 , B : 128 , A : 1 )
let TEXT_ORANGE_COLOR       = RGBA(R: 255 , G : 149 , B : 0 , A : 1)
let TEXT_LIGHTGRAY_COLOR    = RGBA(R: 170 , G : 170 , B : 170 , A :1 )

// MARK: - Func

func RGBA(R : CGFloat, G : CGFloat, B : CGFloat, A : CGFloat) -> UIColor
{
    return UIColor (red : R / 255.0 , green : G / 255.0 , blue : B / 255.0 , alpha : A)
}

func x (object : UIView) -> CGFloat
{
    return object.frame.origin.x
}

func y (object : UIView) -> CGFloat
{
    return object.frame.origin.y
}

func w (object : UIView) -> CGFloat
{
    return object.frame.size.width
}

func h (object : UIView) -> CGFloat
{
    return object.frame.size.height
}

func dPrint(item:@autoclosure () -> Any)
{
    #if DEBUG
        //之所以加上@autoclosure 是因为想延迟对传入的表达式的计算，进一步优化性能
        print(item())
    #endif
}
